package service;

import java.util.HashMap;
import java.util.List;

import model.Businessdict;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;

import dao.BusiDictDao;

@Service
public class BusiDictService {
	@Autowired
	private BusiDictDao busiDictDao;

	public void saveOrUpdate(Businessdict businessdict) {
		if (businessdict.getId() == null) {
			busiDictDao.save(businessdict);
		} else {
			busiDictDao.update(businessdict);
		}
	}

	public void delete(String ids) {
		String[] idStrs = ids.split(",");
		for (String id : idStrs) {
			Integer _id = Integer.parseInt(id);
			busiDictDao.delete(_id);
		}
	}

	public PageList<HashMap<String, Object>> queryPage(int page, int limit,
			HashMap<String, Object> map) {
		PageBounds pageBounds = new PageBounds(page, limit);
		PageList<HashMap<String, Object>> pageList = (PageList<HashMap<String, Object>>) busiDictDao
				.queryPage(pageBounds, map);
		return pageList;
	}

	public List<Businessdict> getByType(String type) {
		return busiDictDao.getByType(type);
	}
}
